package com.tigger.core.redisson.lock;

import com.tigger.core.redisson.DistributedRLocker;

import java.util.concurrent.TimeUnit;

/**
 * Created by root on 2018/7/21.
 */
public class RedissonRLock {

    private static DistributedRLocker distributedRLocker;

    public static void setLocker(DistributedRLocker locker) {
        distributedRLocker = locker;
    }

    public static boolean lock(String lockKey) {
        return distributedRLocker.lock(lockKey);
    }

    public static boolean lock(String lockKey, int timeout) {
        return distributedRLocker.lock(lockKey, timeout);
    }

    public static boolean lock(String lockKey, TimeUnit unit , int timeout) {
        return distributedRLocker.lock(lockKey, unit, timeout);
    }

    public static boolean tryLock(String lockKey, TimeUnit unit, int waitTime, int leaseTime) {
        return distributedRLocker.tryLock(lockKey, unit, waitTime, leaseTime);
    }

    public static void unlock(String lockKey) {
        distributedRLocker.unlock(lockKey);
    }

}
